<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use app\modules\backend\rbac\components\MenuHelper;
use yii\helpers\Url;

AppAsset::register($this);
$this->registerCssFile('@web/css/index.css');

?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>

<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">
                <img alt="Brand" src="<?php echo Url::to('@web/images/logo.png')?>">
            </a>
            <a class="navbar-brand comname" href="#">智慧农业平台</a>

        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <?php
         $menuItems = array();
        $menuItems=[
            ['label'=>'实时监控','url'=>['site/index']],
            ['label'=>'数据报表','url'=>['#']],
            ['label'=>'质量溯源','items'=>[
                ['label'=>'溯源查询','url'=>['product/detail']],
                ['label'=>'溯源管理','url'=>['product/index']],
            ],'options'=>['class'=>'submenu']
            ],
            ['label'=>'生产管理','url'=>['#']],
            ['label'=>'在线交流','url'=>['#']],

        ];



        if(Yii::$app->user->isGuest){
            $menuItems[] = ['label' => '注册', 'url' => ['/site/signup']];
            $menuItems[] = ['label' => '登入', 'url' => ['/site/login']];
        }else {
            $menuItems[] =  ['label'=>Yii::$app->user->identity->username,'items'=>[
                ['label'=>'用户信息', 'url' => ['site/user']],
                ['label' => '注销', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']],

            ]];
        }

        echo Nav::widget([
            'options' => ['class' => 'navbar-nav navbar-right'],
            'items' => $menuItems,
            'id' => 'menulist',
        ]);
        ?>
    </div><!-- /.container-fluid -->
</nav>

    <div class="container">
        <?= Breadcrumbs::widget([
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
        ]) ?>
        <?= $content ?>
    </div>
</div>



<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
